function arrayToTreeRec(nodes, parentId = null) {
    return nodes
        .filter((node) => node.parentId === parentId)
        .map((node1) => {
            return { ...node1, children: arrayToTreeRec(nodes, node1.id) };
        });
}
